package com.atguigu.flink.streamapi.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

/**
 * Created by Smexy on 2022/11/19
 *
 *      简单的数据源，一般用于测试
 */
public class Demo1_SimpleSource
{
    public static void main(String[] args) {

        
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //直接提供数据
        DataStreamSource<Integer> ds = env.fromElements(1, 2, 3, 4, 5, 6);

        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6);
        //从集合中回去
        DataStreamSource<Integer> ds1 = env.fromCollection(list);

        ds1.print();

        ds.print();


        try {
                    env.execute();
                } catch (Exception e) {
                    e.printStackTrace();
                }
        
    }
}
